package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.dto.LoginDTO;
import com.example.demo.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "用户管理")
@RestController
@RequestMapping("/api/user")
public class UserController {

    @Resource
    private UserService userService;

    @ApiOperation("用户登录")
    @PostMapping("/login")
    public Result<LoginDTO> login(
            @ApiParam("登录名") @RequestParam String loginName,
            @ApiParam("密码") @RequestParam String password) {
        return userService.login(loginName, password);
    }

    @ApiOperation("用户登出")
    @PostMapping("/logout")
    public Result<Void> logout(
            @ApiParam("用户token") @RequestParam String token) {
        return userService.logout(token);
    }
} 